/**
 * String extension
 * 
 * @author Mark
 * 
 * @version 1.0 ywengineer@gmail.com
 * 
 */
String.prototype.isEmpty = function() {
	if (this == null || this == "undefined" || this.trim() == "") {
		return true;
	}
	return false;
};

String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
};

String.prototype.isDigit = function() {
	return this.match(/^[1-9][0-9]*$/) != null;
};

String.prototype.isNumber = function() {
	return this.match(/^[0-9]+$/) != null;
};

String.prototype.isAuthCode = function () {
	return this.match(/^[A-Za-z0-9]{4}$/) != null;
};

String.prototype.containChinese = function() {
	return this.match(/[u4E00-u9FA5]+/);
};

// 是否全部是半角
String.prototype.isAlpha = function () {
	for (var i = 0 ; i < this.length ; i ++) {
		if (this.charCodeAt(i) > 65248) {
			return false;
		}
	}
	return true;
};

String.prototype.isEmail = function (){
	return this.match(/^['_A-Za-z0-9-]+(\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$/) != null;
};

String.prototype.isCellPhone = function () {
	return this.match(/^13[0-9]{9}$/) != null;
};

String.prototype.containsEmptyString = function() {
	return this.match(/\s/g) != null;
};

String.prototype.ltrim = function() {
	return this.replace(/(^\s*)/g, "");
};

String.prototype.rtrim = function() {
	return this.replace(/(\s*$)/g, "");
};